//
//  ViewController.m
//  transform
//
//  Created by J on 16/3/4.
//  Copyright © 2016年 J. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
@property(nonatomic,strong)UIView* tempView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    UIView* tempView = [[UIView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];
    tempView.layer.anchorPoint = CGPointMake(0, 1);
    tempView.backgroundColor = [UIColor orangeColor];
    [self.view addSubview:tempView];
    self.tempView = tempView;

}


-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{

    [UIView animateWithDuration:0.3 animations:^{
        
//        CGAffineTransform transform = CGAffineTransformRotate(self.tempView.transform, M_PI_4);//拿到之前的累加

//        CGAffineTransform transform = CGAffineTransformScale(self.tempView.transform, 0.5,0.5);//拿到之前的累加

//       self.tempView.transform =  transform;
        
        //形变属性,能完成的功能平移缩放旋转  本质才是操作了属性x,y
        //平移
//        self.tempView.transform = CGAffineTransformMakeTranslation(-100, 100);
        
        //缩放
//        self.tempView.transform = CGAffineTransformMakeScale(0.5, 0.5);//中心点缩放
        
        //旋转
//        self.tempView.transform = CGAffineTransformMakeRotation(-M_PI_4);
        
        
        //效果叠加
//        CGAffineTransform translation = CGAffineTransformMakeTranslation(-100, 100);
//       CGAffineTransform scaleTransform  = CGAffineTransformScale(translation, 0.5, 0.5);//边平移边缩放 两个叠加
//        CGAffineTransform scaleTransRotate  = CGAffineTransformRotate(scaleTransform, M_PI_4);//边平移边缩放 三个叠加
//
//        self.tempView.transform = scaleTransRotate;
        
        
        self.tempView.transform = CGAffineTransformIdentity;//清楚所有transform属性
    }];
    
}


@end
